<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-save">
        <input type="hidden" name="id" id="id" value="{$data.id}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>上级栏目：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <span class="select-box">
                    <select class="select" name="parent_id" title="上级栏目">
                        <option value="0" {eq name='data.parent_id' value="0" }selected{/eq}>--顶级栏目--</option>
                        {foreach $list as $value}
                        <option value="{$value.id}" {eq name='value.id' value="$data.parent_id" }selected{/eq}>
                            {$value.name}</option>
                        {notempty name="value.child"} {foreach $value.child as $val}
                        <option value="{$val.id}" {eq name='val.id' value="$data.parent_id" }selected{/eq}>&nbsp;&nbsp;└
                            --{$val.name}</option>
                        {/foreach} {/notempty} {/foreach}
                    </select>
                </span>
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>栏目名称：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <input type="text" class="input-text" value="{$data.name}" placeholder="请填写栏目名称" id="name" name="name">
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span> 类型：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <span class="select-box">
                    <select class="select" name="type" title="类型">
                        <option value="0" {eq name='data.type' value="0" }selected{/eq}> 一般栏目 </option>
                        <option value="1" {eq name='data.type' value="1" }selected{/eq}> 目录 </option>
                        <option value="2" {eq name='data.type' value="2" }selected{/eq}> 单页 </option>
                        <option value="3" {eq name='data.type' value="3" }selected{/eq}> 锚点 </option>
                        <option value="4" {eq name='data.type' value="4" }selected{/eq}> 链接 </option>
                    </select>
                </span>
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                路由or绑定url：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <input type="text" class="input-text" value="{$data.url}" placeholder="绑定路由地址或路由" id="url" name="url">
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                模块名：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <input type="text" class="input-text" value="{$data.module}" placeholder="一般栏目(终极)请填写模块名"
                    id="module" name="module">
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                栏目SEO标题：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <input type="text" class="input-text" value="{$data.title}" placeholder="SEO标题" id="title" name="title">
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                栏目SEO关键字：</label>
            <div class="formControls col-xs-8 col-sm-7">
                <input type="text" class="input-text" value="{$data.keywords}" placeholder="SEO关键字" id="keywords"
                    name="keywords">
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">栏目SEO描述：</label>
            <div class="formControls col-xs-8 col-sm-6">
                <textarea name="description" id="description" cols="" rows="" class="textarea"
                    placeholder="SEO描述...最多输入500个字符" onKeyUp="textarealength(this,500)">{$data.description}</textarea>
                <p class="textarea-numberbar">
                    <em class="textarea-length">0</em>/500
                </p>
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-6">
                <textarea name="remark" id="remark" cols="" rows="" class="textarea" placeholder="备注...最多输入500个字符"
                    onKeyUp="textarealength(this,500)">{$data.remark}</textarea>
                <p class="textarea-numberbar">
                    <em class="textarea-length">0</em>/500
                </p>
            </div>
            <div class="col-3"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">排序：</label>
            <div class="formControls col-xs-8 col-sm-6">
                <input type="number" min=0 max=100 class="input-text" value="{$data.sort}" name="sort"
                    style="width:120px;">
                <span class="c-red">数字越小, 越靠前</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red"></span>导航：</label>
            <div class="formControls col-xs-8 col-sm-6">
                <div class="radio-box">
                    <input type="radio" name="is_nav" id="is_menu-1" value="1" {$data.is_nav==1 ? 'checked' : "" }>
                    <label for="is_menu-1">是</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="is_nav" id="is_menu-2" value="0" {$data.is_nav==0 ? 'checked' : "" }>
                    <label for="is_menu-2">否</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red"></span>新标签打开：</label>
            <div class="formControls col-xs-8 col-sm-6">
                <div class="radio-box">
                    <input type="radio" name="is_blank" id="is_blank-1" value="1" {$data.is_blank==1 ? 'checked' : "" }>
                    <label for="is_blank-1">是</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="is_blank" id="is_blank-2" value="0" {$data.is_blank==0 ? 'checked' : "" }>
                    <label for="is_blank-2">否</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" id="form-save-button" name="">确&nbsp;定</button>
                <button type="button" class="btn btn-default radius" onclick="layer_close();"
                    style="margin-left:20px;">取&nbsp;消</button>
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {
        $("#form-save-button").click(function () {
            var data = $("#form-save").serializeArray();
            $.ajax({
                type: 'POST',
                url: '{:url("/sys/category/save")}',
                data: data,
                dataType: 'json',
                success: function (res) {
                    // console.log(res);
                    if (res.code == 0) {
                        layer.msg(res.msg, { icon: 1 }, function () {
                            parent.location.reload(); // 父页面刷新
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 1000
                        });
                        return false;
                    }
                }
            })
        })
    })
</script>
